# -*- coding: UTF-8 -*-
from PIL import Image
from PIL.ExifTags import TAGS
import picmap
"""
获取图片坐标信息  
"""
def getpos(name,ret={}):
            img=Image.open(name)
            if hasattr(img,'_getexif'):
                exifinfo=img._getexif()
                if exifinfo !=None:
                    for tag,value in exifinfo.items():
                        decoded=TAGS.get(tag,tag)
                        ret[decoded]=value
                    # print(ret['GPSInfo']); 
                    N1 = ret['GPSInfo'][2][0]
                    N2 = ret['GPSInfo'][2][1]
                    N3 = ret['GPSInfo'][2][2]
                    N=int(N1)+int(N2)*(1.0/60)+int(N3)*(1.0/360000)
                    E1 = ret['GPSInfo'][4][0]
                    E2 = ret['GPSInfo'][4][1]
                    E3 = ret['GPSInfo'][4][2]
                    E=int(E1)+int(E2)*(1.0/60)+int(E3)*(1.0/360000)

                    return picmap.unilGps.wgs2bd(E,N)
                    # return [str(E),str(N)]

"""
显示图片  
"""
def show(file):
    im = Image.open(file)
    im.show()
#    L = I.convert('L')
#    L.show()


